class Solution:
    def getSmallestString(self, n: int, k: int) -> str:
        res = ['a' for _ in range(n)]
        i = len(res) - 1
        k -= n
        while k >= 25:
            res[i] = 'z'
            i -= 1
            k -= 25
        if i >= 0:
            res[i] = chr(ord('a') + k)

        return ''.join(res)
